import 'package:flutter/widgets.dart';
import 'package:flutter_web_plugins/url_strategy.dart';
import 'package:website/app/presentation/widget/widget.dart';
import 'package:website/injection_container.dart' as di;
import 'package:website.core/core/domain/config/config.dart';
import 'package:website.core/core/domain/config/environment.dart';

Future<void> mainCommon({
  required Environment environment,
}) async {
  WidgetsFlutterBinding.ensureInitialized();

  setUrlStrategy(PathUrlStrategy());

  if (environment.isDev) {
    await Config().initDev();
  } else if (environment.isStage) {
    await Config().initStage();
  } else if (environment.isProd) {
    await Config().initProd();
  }

  await Future.wait([
    di.init(),
  ]);

  runApp(const AppWidget());
}
